//package com.simon.mengkou.ui.adapter;
//
//import android.content.Context;
//import android.support.v4.view.PagerAdapter;
//import android.util.SparseArray;
//import android.view.LayoutInflater;
//import android.view.View;
//import android.view.ViewGroup;
//import android.widget.ImageView;
//
//import com.facebook.drawee.view.SimpleDraweeView;
//import com.ouertech.android.agm.lib.base.utils.UtilDevice;
//import com.ouertech.android.agm.lib.base.utils.UtilList;
//import com.ouertech.android.agm.lib.base.utils.UtilLog;
//import com.ouertech.android.agm.lib.base.utils.UtilString;
//import com.simon.mengkou.R;
//import com.simon.mengkou.data.bean.base.Follow;
//import com.simon.mengkou.data.bean.base.Topic;
//import com.simon.mengkou.system.global.OuerApplication;
//import com.simon.mengkou.system.global.OuerDispatcher;
//import com.simon.mengkou.ui.fragment.HomeFragment;
//import com.simon.mengkou.utils.UtilOuer;
//
//import java.util.List;
//
//import io.vov.vitamio.MediaPlayer;
//import io.vov.vitamio.widget.MediaController;
//import io.vov.vitamio.widget.MediaController2;
//import io.vov.vitamio.widget.VideoView;
//import io.vov.vitamio.widget.VideoView2;
//
///**
// * Created by xiazhenshui on 16/6/13.
// */
//
//public class VideoPagerAdapter extends PagerAdapter {
//    private HomeFragment mFragment;
//    private Context mContext;
//    private List<Follow> mDatas;
//    private SparseArray<View> mViews;
//    private boolean mPlayable;
//
//    public VideoPagerAdapter(Context context, HomeFragment fragment, List<Follow> datas) {
//        this.mContext = context;
//        this.mDatas = datas;//构造方法，参数是我们的页卡，这样比较方便。
//        this.mViews = new SparseArray<>(4);
//        this.mFragment = fragment;
//        this.mPlayable = true;
//    }
//
//    @Override
//    public void destroyItem(ViewGroup container, int position, Object object) 	{
//        View view = mViews.get(position);
//        if(view != null) {
//            container.removeView(mViews.get(position));//删除页卡
//        }
//    }
//
//
//    @Override
//    public Object instantiateItem(ViewGroup container, final int position) {	//这个方法用来实例化页卡
//        View view = mViews.get(position);
//        if(view == null) {
//            view = LayoutInflater.from(mContext).inflate(R.layout.layout_top_video_image_item, null);
//            SimpleDraweeView sdvImage = (SimpleDraweeView) view.findViewById(R.id.image_id_image);
//            OuerApplication.mImageLoader.loadImage(sdvImage, mDatas.get(position).getVideoCover());
//            sdvImage.setOnClickListener(new View.OnClickListener() {
//                @Override
//                public void onClick(View v) {
//                    if(mPlayable) {
//                        OuerDispatcher.presentShareOrderDetailActivity(mContext, mDatas.get(position));
//                    }
//                }
//            });
//            final ImageView ivVideo = (ImageView)view.findViewById(R.id.home_id_video_play);
//
//            ivVideo.setOnClickListener(new View.OnClickListener() {
//                @Override
//                public void onClick(View v) {
//                    if(mPlayable) {
//                        mFragment.playVideo(mDatas.get(position));
//                    }
//                }
//            });
//
//
//            mViews.put(position, view);
//        }
//
//        container.addView(view);//添加页卡
//        return mViews.get(position);
//    }
//
//    @Override
//    public int getCount() {
//        return UtilList.getCount(mDatas);//返回页卡的数量
//    }
//
//    @Override
//    public boolean isViewFromObject(View arg0, Object arg1) {
//        return arg0==arg1;//官方提示这样写
//    }
//
//    public void setList(List<Follow> datas) {
//        mDatas = datas;
//        mViews.clear();
//        notifyDataSetChanged();
//    }
//
//    public Follow getItem(int position) {
//        return mDatas.get(position);
//    }
//
//    public List<Follow> getData() {
//        return mDatas;
//    }
//
//    public void setPlayable(boolean playable) {
//        this.mPlayable = playable;
//    }
//}
